package com.xauto.pioneer.appuser.adapter;

import android.app.Activity;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.TextView;

import com.xauto.pioneer.appuser.R;
import com.xauto.pioneer.appuser.model.OrderInfo;
import com.xauto.pioneer.appuser.model.ParkingSite;

/**
 * Created by Lemon on 2015/12/11.
 * Desc:订单列表 适配器
 */
public class OrderAdapter extends AbsAdapter<OrderInfo> {

    public OrderAdapter(Activity context, int layout) {
        super(context, layout);
    }

    @Override
    public ViewHolder<OrderInfo> getHolder() {
        return new TemplateViewHolder();
    }


    private class TemplateViewHolder implements ViewHolder<OrderInfo> {

        private TextView tvOrderNo;
        private TextView tvOrderStatus;
        private TextView tvOrderDate;
        private TextView tvOrderExtend;
        private TextView tvOrderAccount;

        @Override
        public void initViews(View v, int position) {
            tvOrderNo = (TextView) v.findViewById(R.id.tvOrderNo);
            tvOrderStatus = (TextView) v.findViewById(R.id.tvOrderStatus);
            tvOrderDate = (TextView) v.findViewById(R.id.tvOrderDate);
            tvOrderExtend = (TextView) v.findViewById(R.id.tvOrderExtend);
            tvOrderAccount = (TextView) v.findViewById(R.id.tvOrderAccount);
        }

        @Override
        public void updateData(OrderInfo orderInfo, int position) {
            tvOrderNo.setText(context.getString(R.string.order_no,orderInfo.car_order_no));
            tvOrderDate.setText(context.getString(R.string.order_date,orderInfo.order_time_format));
            tvOrderAccount.setText(context.getString(R.string.order_account,orderInfo.total_amount_format));
//            tvOrderStatus.setText(orderInfo.car_order_status_name);
            tvOrderStatus.setText(orderInfo.car_order_status_display_name );
            tvOrderExtend.setVisibility("1".equals(orderInfo.is_extend_info) ? View.VISIBLE : View.GONE);
        }

        @Override
        public void doOthers(OrderInfo orderInfo, int position) {

        }
    }
}
